package xyz.thoughtset.viewer.executor.core.base;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import xyz.thoughtset.viewer.executor.core.entity.QueryBody;
import xyz.thoughtset.viewer.executor.core.factory.ExecutorRegistry;

import java.util.Map;

public abstract class AbstractExecutor {
    @Getter
    protected final String supportType;
    @Getter
    protected final boolean innerExecutor;
    @Autowired
    protected ObjectMapper objectMapper;


    protected AbstractExecutor(String supportType, boolean innerExecutor){
        this.supportType = supportType;
        this.innerExecutor = innerExecutor;
        ExecutorRegistry.register(this);
    }

    public Object execute(QueryBody queryBody, Map param){
        return exec(queryBody,param);
    }

    abstract protected Object exec(QueryBody queryBody,Map dataContext);

}
